package com.jx.controller.admin.system;

import com.jx.common.result.AjaxResult;
import com.jx.pojo.po.system.LoginPO;
import com.jx.pojo.vo.system.LoginVO;
import com.jx.service.system.LoginService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
public class LoginController {

    @Resource
    private LoginService loginService;

    /**
     * 用户登录
     */
    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginVO loginVO) {
        LoginPO loginPO = loginService.login(loginVO);
        return AjaxResult.success("登录成功", loginPO);
    }

    /**
     * 用户退出
     */
    @PostMapping("/logout")
    public AjaxResult logout(HttpServletRequest request) {
        loginService.logout(request);
        return AjaxResult.success("退出成功");
    }

}
